package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.transmit.domain.TemperAreaConfig;
import com.lvy.hczn.transmit.service.TemperAreaConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.lvy.hczn.front.common.annotation.Log;
import com.lvy.hczn.front.common.enums.BusinessType;
import com.lvy.hczn.front.common.core.controller.BaseController;
import com.lvy.hczn.front.common.core.domain.AjaxResult;

@Controller
@RequestMapping("/api/dt/temper/")
@Slf4j
public class TemperAreaConfigController extends BaseController {

    @Autowired
    private TemperAreaConfigService temperAreaConfigService;

    @Log(title = "平台温区配置表新增记录到数据中心", businessType = BusinessType.DELETE)
    @PostMapping("addData")
    @ResponseBody
    public AjaxResult addData(@RequestBody TemperAreaConfig temperAreaConfig) {
        try {
            temperAreaConfigService.addData(temperAreaConfig);
        } catch (Exception e) {
            log.error("addData：平台温区配置表：{}", e);
            return AjaxResult.error("同步异常");
        }
        return AjaxResult.success();
    }

    @Log(title = "同步温区配置表接口", businessType = BusinessType.OTHER)
    @PostMapping("syncTemperArea")
    @ResponseBody
    public AjaxResult syncTemperArea() {
        return AjaxResult.success(temperAreaConfigService.syncTemperArea());
    }
}
